<?php
/**
 * Page Template
 *
 * Loaded automatically by index.php?main_page=shopping_cart.<br />
 * Displays shopping-cart contents
 *
 * @package templateSystem
 * @copyright Copyright 2003-2010 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_shopping_cart_default.php 15881 2010-04-11 16:32:39Z wilt $
 */
?>
<div class="centerColumn" id="shoppingCartDefault">
<?php
  if ($flagHasCartContents) {
?>

<?php
  if ($_SESSION['cart']->count_contents() > 0) {
?>
<!-- 
<div class="forward"><?php echo TEXT_VISITORS_CART; ?></div>
 -->
<?php
  }
?>

<!-- <h1 id="cartDefaultHeading"><?php echo HEADING_TITLE; ?></h1>  -->

<!-- start 流程 -->
<div class="order_wrapper">
        	<h2><img src="images/order/tit_flow.png" /><span>感谢您花时间在本站购物，现在只需简单几步就能完成购物，谢谢您的耐心！</span></h2>
            <img src="images/order/img_flow_step_1.png" /> 
        </div>
<!-- end 流程 -->

<!-- start notice -->

<!-- end notice -->

<?php if ($messageStack->size('shopping_cart') > 0) echo $messageStack->output('shopping_cart'); ?>

<?php echo zen_draw_form('cart_quantity', zen_href_link(FILENAME_SHOPPING_CART, 'action=update_product', $request_type),"post","id=cart_quantity"); ?>

<?php  if ($flagAnyOutOfStock) { ?>

<?php    if (STOCK_ALLOW_CHECKOUT == 'true') {  ?>

<div class="messageStackError"><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></div>

<?php    } else { ?>
<div class="messageStackError"><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></div>

<?php    } //endif STOCK_ALLOW_CHECKOUT ?>
<?php  } //endif flagAnyOutOfStock ?>
<div class="order_wrapper">
       	<h2><img src="images/order/tit_list.png" /><span>这是您挑选的商品，您可以修改产品数量，删除相关产品或者返回其他页面继续购物。</span></h2>
       
<table width="100%" border="0"  class="order_list">
     <tr >
        <th>序号</th>
    <th>商品</th>
    <th>规格</th>
    <th>单价(元)</th>
    <th>折后价(元)</th>
    <th>数量</th>
    <th>小计(元)</th>
    <th>删除</th>
     </tr>
         <!-- Loop through all products /-->
<?php
$no = 1;
  foreach ($productArray as $product) {
      //GET ATTRIBUTE
        $price = zen_get_products_display_price_main((int)$product['id']);
            $special_price = $price["special_price"];
            $normal_price = $price["normal_price"];
?>
     <tr >
       <td>
<?php 
echo $no;

$no = $no + 1;
?>
       </td>
       <td class="cart_product_thumb">
<!-- update quarty -->
<a href="<?php echo $product['linkProductsName']; ?>"><?php echo $product['productsImage']; ?><?php echo $product['productsName'] ; ?></a>
       </td>
<!-- product -->
       <td id="cart_product_attrib">
<?php
  echo $product['attributeHiddenField'];
  if (isset($product['attributes']) && is_array($product['attributes'])) {
  echo '<div class="cartAttribsList">';
  echo '<ul>';
    reset($product['attributes']);
    foreach ($product['attributes'] as $option => $value) {
?>

<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?></li>

<?php
    }
  echo '</ul>';
  echo '</div>';
  }
?>
</td>

	   <td id="cart_product_nor_price"><?php echo $normal_price;?> </td>

       <td class="sale_price"><?php  echo $special_price;?></td>
       
       <td class="cart_update_quantity">
      
       <?php
      // echo $product['quantity'];    //产品数量
      echo '<input name="cart_quantity[]" size="5" length="5" value="'.$product['quantity'].'">';
      echo '<input type="image" src="images/genggai.jpg" />';    //得用这样才行
      echo zen_draw_hidden_field('products_id[]', $product['id']);
//数量更新
//  if ($product['flagShowFixedQuantity']) {
//    echo $product['showFixedQuantityAmount'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];
//  } else {
//    echo $product['quantityField'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];
//  }
?>

<?php
//  if ($product['buttonUpdate'] == '') {
//    echo '' ;
//  } else {
//    echo $product['buttonUpdate'];
//  }
?>
       </td>
       <td id="nroprice"><?php 
       if($special_price != "")
           echo $product['quantity'] * $special_price;
       else
           echo $product['quantity'] * $normal_price;
       ?></td>
       <td id="cartRemoveItemDisplay">
<?php
  if ($product['buttonDelete']) {
?>
           <a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, 'action=remove_product&product_id=' . $product['id']); ?>">
           <?php echo zen_image($template->get_template_dir(ICON_IMAGE_TRASH, DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . ICON_IMAGE_TRASH, ICON_TRASH_ALT); ?></a>
			
         
<?php
  }
  
?>
</td>
     </tr>
<?php
  } // end foreach ($productArray as $product)
?>
       <!-- Finished loop through all products /-->
      </table>

<!-- start submit -->

<!-- <div id="cartSubTotal">
<?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $cartShowTotal; ?></div>
 -->


<div class="order_list_submit clearfix">
    <div class="list_clear">
    <?php echo zen_image_submit(ICON_IMAGE_UPDATE, ICON_UPDATE_ALT,'id="update" style="display:none"'); ?>
    
    	<a onclick="javascript:clearCart();" class="btn_clear">清空购物车，我不需要购物车的所有商品。</a>
    
    </div>
    <div class="total_amount">
    	<sup>￥</sup><?php echo $cartShowTotal; ?>
    </div>
    <div class="total_amount_right">
    </div>
    <div class="promotion_code">
    	<div class="code_input">优惠码 <input type="text" id="code_discount" /> <input type="button" value="OK" class="btn_ok" /></div>
    </div>
	<br class="clearBoth"/>
</div>

</div> <!-- eof table shop wipper -->

<div class="process_control clearfix">
    <div class="ad_promotion">
        <a href="#"><img src="images/order/ad_promotion.gif" /></a>
    </div>
    <div class="btn_wrapper clearfix">
    	<a class="btn_next_fill_info" href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL');?>"></a>
        <a href="index.php" class="btn_back_to_shop"></a>
    </div>
</div>
</div><!-- end submit -->
</form>

<!-- end notice 2 -->

<!-- ** BEGIN PAYPAL EXPRESS CHECKOUT ** -->
<?php  // the tpl_ec_button template only displays EC option if cart contents >0 and value >0
if (defined('MODULE_PAYMENT_PAYPALWPP_STATUS') && MODULE_PAYMENT_PAYPALWPP_STATUS == 'True') {
  include(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/paypal/tpl_ec_button.php');
}
?>
<!-- ** END PAYPAL EXPRESS CHECKOUT ** -->

<?php
      if (SHOW_SHIPPING_ESTIMATOR_BUTTON == '2') {
/**
 * load the shipping estimator code if needed
 */
?>
      <?php require(DIR_WS_MODULES . zen_get_module_directory('shipping_estimator.php')); ?>

<?php
      }
?>
<?php
  } else {
?>
<h2 id="cartEmptyText"><?php echo TEXT_CART_EMPTY; ?></h2>

<script language="javascript" type="text/javascript"> 
window.location.href="http://www.yeps.cn"; 
</script> 
<?php
  }
?>
</div>

<script language="javascript">
<!--
function onSubmitCart(){
	var discount_code = $("#code_discount").val();
	var discount = "<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL');?>";
	discount = discount + "&code=" +discount_code;
	//alert(discount);
	window.location.href=discount;
	//$("#cart_quantity").submit();
	
}
function clearCart(){
	$("input[name='cart_quantity[]']").each(
		function(){
			$(this).val(0);
			}
	);
	$("#update").click();
}
-->
</script>
